App({
  globalData:{
    userInfo:null
  },
  onLaunch() {
    wx.login({
      success(res){
        if(res.code){
          // console.log(res.code);
          wx.request({
            url: 'https://api.it120.cc/fxy/user/wxapp/authorize',
            method: 'POST',
            data:{code:res.code},
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              console.log(res.data);
              if (res.data.code == 0) {
                wx.setStorageSync('uid', res.data.data.uid)
                wx.setStorageSync('token', res.data.data.token)
                wx.setStorageSync('openid', res.data.data.openid)
              }
            },
            fail: function (err) {
              // console.log(err);
            }
          })
        } else {

        }
      },
      fail(error) {
        console.log(error + '错误');
      }
    })
  },
  onShow() {
    
  }
})